﻿@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

<div @attributes="@AdditionalAttributes" class="@ClassString" @ref="CollapseElement">
    <CascadingValue Value="this" IsFixed="true">
        @CollapseItems
    </CascadingValue>
    <RenderTemplate>
        @foreach (var item in Items)
        {
            <div class="@GetItemClassString(item)">
                <div class="accordion-header">
                    <Button class="@GetButtonClassString(item)" data-bs-toggle="collapse" aria-expanded="@(item.IsCollapsed ? "false" : "true")" Color="Color.None" Text="@item.Text" OnClickWithoutRender="@(() => OnClickItem(item))" Icon="@item.Icon" />
                </div>
                <div class="@GetClassString(item.IsCollapsed)">
                    <div class="accordion-body">
                        @item.ChildContent
                    </div>
                </div>
            </div>
        }
    </RenderTemplate>
</div>
